
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.js"></script>
</head>
<body>
  <input id="first-number" type="number" placeholder="请输入第一个数字">
  <input id="second-number" type="number" placeholder="请输入第二个数字">
  <button id="sum-action" onclick="getSum()">求和</button>
  <p id="sum">
    两个输入框之和为 <span id="result"></span>
  </p>

  <script>
    var input1 = $("#first-number");
    var input2 = $("#second-number");
    var resultContent = $("#result")

    function getSum() {
      var input1Value = input1.val() - 0
      var input2Value = input2.val() - 0
      var sum = input1Value + input2Value
      resultContent.html(sum)
    }

  </script>
</body>

</html>